package c.e.c;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.PopupWindow;
import android.widget.TextView;
import b.b.k.k;
import bin.mt.plus.TranslationData.R;
import com.player.activity.PlayerActivity;
import com.player.views.RVListView;
import java.io.File;
import java.util.ArrayList;
import java.util.Hashtable;
import setting.MySettings;
public class o1 {
    public static int r = 1;
    public static int s;
    public static int t;
    public static ArrayList<String> u;
    public TextView a;
    public TextView aa;
    public z0 b;
    public y0 c;
    public c.e.b.d d;
    public View e;
    public View f;
    public Context g;
    public PopupWindow h;
    public RVListView i;
    public RVListView j;
    public m1 l;
    public a m;
    public Runnable n;
    public View p;
    public ImageView v;
    public Button w;
    public PopupWindow x;
    public View y;
    public boolean k = true;
    public Handler o = new Handler();
    public boolean q = false;

    public interface a {
    }

    public class b implements View.OnClickListener {
        public b() {
        }

        @Override
        public void onClick(View view) {
            o1.this.x.dismiss();
            o1 o1Var = o1.this;
            if (o1Var == null) {
                throw null;
            }
            PopupWindow popupWindow = new PopupWindow(o1Var.y, -1, -1);
            popupWindow.setBackgroundDrawable(new ColorDrawable(Color.argb(191, 0, 0, 0)));
            popupWindow.setFocusable(true);
            popupWindow.setOutsideTouchable(true);
            popupWindow.update();
            popupWindow.showAtLocation(o1Var.p, 8388611, 0, 0);
            o1Var.h.dismiss();
        }
    }

    public o1(Context context, c.e.b.d dVar) {
        this.g = context;
        this.d = dVar;
        LayoutInflater from = LayoutInflater.from(context);
        Bitmap bitmap = null;
        this.p = from.inflate(R.layout.layout001d, (ViewGroup) null);
        View inflate = from.inflate(R.layout.layout0036, (ViewGroup) null);
        this.f = inflate;
        this.i = (RVListView) inflate.findViewById(R.id.id00cc);
        this.j = (RVListView) this.f.findViewById(R.id.id00cd);
        TextView textView = new TextView(this.g);
        textView.setTextSize(0, j1.b);
        int measureText = (int) textView.getPaint().measureText("设置选项宽度很");
        ViewGroup.LayoutParams layoutParams = this.j.getLayoutParams();
        layoutParams.width = measureText;
        this.j.setLayoutParams(layoutParams);
        ViewGroup.LayoutParams layoutParams2 = this.i.getLayoutParams();
        layoutParams2.width = measureText;
        this.i.setLayoutParams(layoutParams2);
        this.y = from.inflate(R.layout.layout0038, (ViewGroup) null);
        View inflate2 = from.inflate(R.layout.layout0040, (ViewGroup) null);
        this.e = inflate2;
        this.aa = (TextView) inflate2.findViewById(R.id.id0167);
        this.v = (ImageView) this.e.findViewById(R.id.id0168);
        this.w = (Button) this.e.findViewById(R.id.id0169);
        TextView textView2 = this.aa;
        StringBuilder a2 = c.b.a.a.a.a("请保持当前设备和扫描手机在同一局域网\n浏览器输入http://");
        a2.append(c.e.d.h.a());
        a2.append(":");
        a2.append(1991);
        textView2.setText(a2.toString());
        this.aa.setTextSize(0, j1.b);
        ViewGroup.LayoutParams layoutParams3 = this.w.getLayoutParams();
        layoutParams3.width = j1.a.x / 5;
        layoutParams3.height = j1.e;
        this.w.setLayoutParams(layoutParams3);
        this.w.setTextSize(0, (j1.b * 12) / 10);
        String str = "http://" + c.e.d.h.a() + ":1991";
        int i = (j1.a.y * 2) / 5;
        if (!TextUtils.isEmpty(str) && i >= 0 && i >= 0) {
            try {
                Hashtable hashtable = new Hashtable();
                if (!TextUtils.isEmpty("utf-8")) {
                    hashtable.put(c.c.b.b.c, "utf-8");
                }
                if (!TextUtils.isEmpty("L")) {
                    hashtable.put(c.c.b.b.b, "L");
                }
                if (!TextUtils.isEmpty("0")) {
                    hashtable.put(c.c.b.b.g, "0");
                }
                c.c.b.d.b a3 = new c.c.b.e.a().a(str, c.c.b.a.m, i, i, hashtable);
                int[] iArr = new int[i * i];
                for (int i2 = 0; i2 < i; i2++) {
                    for (int i3 = 0; i3 < i; i3++) {
                        if (a3.a(i3, i2)) {
                            iArr[(i2 * i) + i3] = -16777216;
                        } else {
                            iArr[(i2 * i) + i3] = -1;
                        }
                    }
                }
                Bitmap createBitmap = Bitmap.createBitmap(i, i, Bitmap.Config.ARGB_8888);
                createBitmap.setPixels(iArr, 0, i, 0, 0, i, i);
                bitmap = createBitmap;
            } catch (c.c.b.c e) {
                e.printStackTrace();
            }
        }
        this.v.setImageDrawable(new BitmapDrawable(this.g.getResources(), bitmap));
        ViewGroup.LayoutParams layoutParams4 = this.v.getLayoutParams();
        int i4 = (j1.a.y * 2) / 5;
        layoutParams4.width = i4;
        layoutParams4.height = i4;
        this.v.setLayoutParams(layoutParams4);
        this.w.setOnClickListener(new b());
        TextView textView3 = (TextView) this.y.findViewById(R.id.id013f);
        this.a = textView3;
        StringBuilder a4 = c.b.a.a.a.a("控制台地址：http://");
        a4.append(c.e.d.h.a());
        a4.append(":");
        a4.append(1991);
        a4.append("\n\n本地自定义：设备存储根目录搜寻“");
        a4.append(k.i.b());
        a4.append("”文件夹，并把TXT文本源存储即可！\n\n网络自定义：软件运行状态下在浏览器地址栏输入控制台地址后回车即可自定义！\n\n接口自定义：长按屏幕或遥控菜单调出接口设置，节目地址栏输入或粘贴源地址！\n\n关于本软件：本软件属个人专用线路源，免费使用，定制联系QQ3120176288！\n");
        textView3.setText(a4.toString());
        this.a.setTextSize(0, j1.b);
        m1 a5 = m1.a(dVar.b().f);
        this.l = a5;
        z0 z0Var = new z0(this.g, a5);
        this.b = z0Var;
        this.j.setAdapter(z0Var);
        this.b.e = new h1() {
            @Override
            public final void a(int i5) {
                o1.this.b(i5);
            }
        };
        this.f.setOnKeyListener(new View.OnKeyListener() {
            @Override
            public final boolean onKey(View view, int i5, KeyEvent keyEvent) {
                return o1.this.a(view, i5, keyEvent);
            }
        });
        this.i.a(new n1(this));
        ArrayList<String> arrayList = new ArrayList<>();
        u = arrayList;
        arrayList.add("https://epg.112114.xyz");
        u.add("https://epg.sec.st/epg.php");
        u.add("https://epg.hicloud.co/epg.php");
    }

    public final void a() {
        Runnable runnable = this.n;
        if (runnable == null) {
            this.n = new Runnable() {
                @Override
                public final void run() {
                    o1.this.c();
                }
            };
        } else {
            this.o.removeCallbacks(runnable);
        }
        this.o.postDelayed(this.n, 10000L);
    }

    public void a(int i) {
        s = i;
        this.q = true;
        e();
        a();
    }

    public void a(EditText editText, DialogInterface dialogInterface, int i) {
        String str;
        if (editText.getText().toString().equals("520")) {
            MySettings.get().clearSettings();
            File file = new File(c.e.b.d.c);
            if (!file.exists()) {
                return;
            }
            File[] listFiles = file.listFiles();
            if (listFiles != null) {
                for (File file2 : listFiles) {
                    file2.delete();
                }
            }
            c.e.d.g.f = "";
            PlayerActivity.this.E.sendEmptyMessage(1003);
            str = "所有数据已经清空";
        } else {
            str = "密码输入有误";
        }
        k.i.b((Object) str);
    }

    public boolean a(View view, int i, KeyEvent keyEvent) {
        int i2;
        if (keyEvent.getAction() == 0) {
            if (i != 66) {
                switch (i) {
                    case 19:
                        int i3 = r;
                        if (i3 > 0) {
                            if (i3 == 1 && (i2 = t) > 0) {
                                t = i2 - 1;
                                b();
                                this.b.a(t + 1);
                                this.b.a(t);
                                break;
                            }
                        } else {
                            r = 0;
                            int i4 = s;
                            if (i4 > 0) {
                                int i5 = i4 - 1;
                                s = i5;
                                this.c.a(i5 + 1);
                                this.c.a(s);
                                this.i.d(s);
                                break;
                            }
                        }
                        break;
                    case 20:
                        int i6 = r;
                        if (i6 > 0) {
                            if (i6 == 1 && t < this.l.size() - 1) {
                                t++;
                                b();
                                this.b.a(t - 1);
                                this.b.a(t);
                                break;
                            }
                        } else {
                            r = 0;
                            if (s < this.l.get(t).a.size() - 1) {
                                int i7 = s + 1;
                                s = i7;
                                this.c.a(i7 - 1);
                                this.c.a(s);
                                this.i.d(s);
                                break;
                            }
                        }
                        break;
                    case 21:
                        int i8 = r;
                        if (i8 == 1) {
                            r = i8 - 1;
                            s = 0;
                            this.b.a(t);
                            this.c.a(s);
                            break;
                        }
                        break;
                    case 22:
                        int i9 = r;
                        if (i9 <= 0) {
                            r = i9 + 1;
                            this.b.a(t);
                            this.c.a(s);
                            break;
                        }
                        break;
                }
                a();
            }
            if (r == 0) {
                this.q = false;
                e();
            }
            a();
        }
        return false;
    }

    public void b() {
        try {
            m1 a2 = m1.a(this.d.b().f);
            this.l = a2;
            y0 y0Var = new y0(this.g, a2.get(t));
            this.c = y0Var;
            this.i.setAdapter(y0Var);
            this.c.e = new h1() {
                @Override
                public final void a(int i) {
                    o1.this.a(i);
                }
            };
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void b(int i) {
        t = i;
        b();
        this.b.a.a();
        a();
    }

    public void c() {
        this.h.dismiss();
    }

    public void d() {
        this.o.removeCallbacks(this.n);
        r = this.k ? 1 : -1;
        t = 0;
        this.b.a.a();
    }

    public final void e() {
        char c2;
        StringBuilder sb;
        String str;
        String str2;
        String str3 = this.l.get(t).a.get(s);
        String str4 = this.l.get(t).b;
        switch (str4.hashCode()) {
            case 67316076:
                if (str4.equals("EPG设置")) {
                    c2 = '\b';
                    break;
                }
                c2 = 65535;
                break;
            case 635630334:
                if (str4.equals("偏好设置")) {
                    c2 = '\n';
                    break;
                }
                c2 = 65535;
                break;
            case 660855327:
                if (str4.equals("列表风格")) {
                    c2 = 4;
                    break;
                }
                c2 = 65535;
                break;
            case 781717710:
                if (str4.equals("接口设置")) {
                    c2 = 7;
                    break;
                }
                c2 = 65535;
                break;
            case 810714924:
                if (str4.equals("显示设置")) {
                    c2 = '\t';
                    break;
                }
                c2 = 65535;
                break;
            case 928183580:
                if (str4.equals("省份选择")) {
                    c2 = 6;
                    break;
                }
                c2 = 65535;
                break;
            case 932176382:
                if (str4.equals("画面比例")) {
                    c2 = 1;
                    break;
                }
                c2 = 65535;
                break;
            case 1002714896:
                if (str4.equals("线路选择")) {
                    c2 = 0;
                    break;
                }
                c2 = 65535;
                break;
            case 1081946996:
                if (str4.equals("解码方式")) {
                    c2 = 2;
                    break;
                }
                c2 = 65535;
                break;
            case 1105199167:
                if (str4.equals("超时换源")) {
                    c2 = 5;
                    break;
                }
                c2 = 65535;
                break;
            case 1200063975:
                if (str4.equals("频道管理")) {
                    c2 = 3;
                    break;
                }
                c2 = 65535;
                break;
            default:
                c2 = 65535;
                break;
        }
        switch (c2) {
            case 0:
                a aVar = this.m;
                if (aVar != null) {
                    int i = s;
                    PlayerActivity.c cVar = (PlayerActivity.c) aVar;
                    if (cVar == null) {
                        throw null;
                    }
                    c.e.b.d.i = i;
                    k.i.ai(PlayerActivity.this);
                    break;
                }
                break;
            case 1:
                MySettings.get().saveScreenScale(s);
                a aVar2 = this.m;
                if (aVar2 != null) {
                    int i2 = s;
                    PlayerActivity.c cVar2 = (PlayerActivity.c) aVar2;
                    PlayerActivity.this.p.setScreenScale(i2);
                    PlayerActivity.this.q.setScreenScale(i2);
                    break;
                }
                break;
            case 2:
                MySettings.get().saveMediaCodec(s);
                a aVar3 = this.m;
                if (aVar3 != null) {
                    PlayerActivity playerActivity = PlayerActivity.this;
                    playerActivity.p.n = true;
                    playerActivity.r();
                    break;
                }
                break;
            case 3:
                MySettings.get().toggleHideCategory(str3);
                if (MySettings.get().isCategoryHide(str3)) {
                    sb = new StringBuilder();
                    sb.append(str3);
                    str = "已隐藏";
                } else {
                    sb = new StringBuilder();
                    sb.append(str3);
                    str = "已显示";
                }
                sb.append(str);
                k.i.b((Object) sb.toString());
                a aVar4 = this.m;
                if (aVar4 != null) {
                    PlayerActivity.c cVar3 = (PlayerActivity.c) aVar4;
                    if (cVar3 == null) {
                        throw null;
                    }
                    PlayerActivity.d0 = new c.e.b.d(PlayerActivity.this.r);
                    PlayerActivity.this.j();
                    break;
                }
                break;
            case 4:
                MySettings.get().saveChannelListStyle(s);
                break;
            case 5:
                MySettings.get().saveTimeOut(s);
                break;
            case 6:
                MySettings.get().saveProvince(str3);
                a aVar5 = this.m;
                if (aVar5 != null && ((PlayerActivity.c) aVar5) == null) {
                    throw null;
                }
                break;
            case 7:
                a aVar6 = this.m;
                if (aVar6 != null) {
                    int i3 = s;
                    PlayerActivity.c cVar4 = (PlayerActivity.c) aVar6;
                    if (cVar4 == null) {
                        throw null;
                    }
                    if (i3 != 0) {
                        if (i3 != 1) {
                            if (i3 != 2) {
                                if (i3 == 3) {
                                    PlayerActivity.e(PlayerActivity.this);
                                    break;
                                }
                            } else {
                                PlayerActivity.d(PlayerActivity.this);
                                break;
                            }
                        } else {
                            PlayerActivity.c(PlayerActivity.this);
                            break;
                        }
                    } else {
                        PlayerActivity.b(PlayerActivity.this);
                        break;
                    }
                }
                break;
            case '\b':
                MySettings.get().d(u.get(s));
                str2 = "EPG线路切换成功";
                k.i.b((Object) str2);
                break;
            case '\t':
                if (!str3.equals("显示时间")) {
                    if (!str3.equals("显示网速")) {
                        if (!str3.equals("护眼模式")) {
                            if (!str3.equals("隐藏序号")) {
                                if (!str3.equals("传统列表")) {
                                    if (!str3.equals("列表EPG")) {
                                        if (!str3.equals("赞赏百川")) {
                                            if (!str3.equals("窗口播放")) {
                                                if (str3.equals("自定义源")) {
                                                    PopupWindow popupWindow = new PopupWindow(this.e, j1.a.x / 2, -2);
                                                    this.x = popupWindow;
                                                    popupWindow.setBackgroundDrawable(new ColorDrawable(Color.argb(3, 0, 0, 0)));
                                                    this.x.setFocusable(true);
                                                    this.x.setOutsideTouchable(true);
                                                    this.x.update();
                                                    this.x.showAtLocation(this.p, 17, 0, 0);
                                                    this.h.dismiss();
                                                    this.w.requestFocus();
                                                    break;
                                                }
                                            } else if (this.q) {
                                                PlayerActivity.h(PlayerActivity.this);
                                                break;
                                            }
                                        } else {
                                            if (Drawable.createFromPath(this.g.getFilesDir() + "/sponsor.png") != null) {
                                                throw null;
                                            }
                                            PopupWindow popupWindow2 = new PopupWindow(this.y, 191, 191);
                                            popupWindow2.setBackgroundDrawable(new ColorDrawable(Color.argb(3, 0, 0, 0)));
                                            popupWindow2.setFocusable(true);
                                            popupWindow2.setOutsideTouchable(true);
                                            popupWindow2.update();
                                            popupWindow2.showAtLocation(this.p, 8388611, 0, 0);
                                            this.h.dismiss();
                                            break;
                                        }
                                    } else {
                                        MySettings.get().toggleShowEpgList();
                                        str2 = MySettings.get().isShowEpgList() ? "已显示EPG列表" : "已关闭EPG列表";
                                    }
                                } else {
                                    MySettings.get().toggleShiJiListStyle();
                                    str2 = MySettings.get().isShiJiListStyle() ? "已切换至左右列表风格" : "已切换至上下列表风格";
                                }
                            } else {
                                MySettings.get().toggleHideChannelNum();
                                str2 = MySettings.get().isChannelNumHide() ? "节目序号已隐藏" : "节目序号已显示";
                            }
                        } else {
                            MySettings.get().toggleEyeProtectMode();
                            str2 = MySettings.get().isEyeProtectMode() ? "护眼模式已开启" : "护眼模式已关闭";
                        }
                    } else {
                        MySettings.get().toggleShowNetSpeed();
                        str2 = MySettings.get().isShowNetSpeed() ? "已显示当前网速" : "已关闭网速显示";
                    }
                } else {
                    MySettings.get().toggleShowTime();
                    str2 = MySettings.get().isShowTime() ? "已显示当前时间" : "已关闭时间显示";
                }
                k.i.b((Object) str2);
                break;
            case '\n':
                if (!str3.equals("快速退出")) {
                    if (!str3.equals("玩转原力")) {
                        if (!str3.equals("开启传源")) {
                            if (!str3.equals("记忆进度")) {
                                if (!str3.equals("记忆多源")) {
                                    if (!str3.equals("跨选分类")) {
                                        if (!str3.equals("开机自启")) {
                                            if (!str3.equals("换台反转")) {
                                                if (!str3.equals("开启时移")) {
                                                    if (str3.equals("清除数据")) {
                                                        final EditText editText = new EditText(this.g);
                                                        editText.setSingleLine();
                                                        AlertDialog.Builder builder = new AlertDialog.Builder(this.g);
                                                        builder.setTitle("清除所有数据");
                                                        builder.setMessage("请输入密码并点击确定按钮");
                                                        builder.setView(editText);
                                                        builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
                                                            @Override
                                                            public final void onClick(DialogInterface dialogInterface, int i4) {
                                                                o1.this.a(editText, dialogInterface, i4);
                                                            }
                                                        });
                                                        builder.setNegativeButton("取消", p0.b);
                                                        builder.show();
                                                        break;
                                                    }
                                                } else {
                                                    MySettings.get().toggleShowSeekBack();
                                                    str2 = MySettings.get().isShowSeekBack() ? "已开启时移" : "已关闭时移";
                                                }
                                            } else {
                                                MySettings.get().toggleSwitchStyle();
                                                str2 = MySettings.get().isReverseSwitchStyle() ? "已反转换台模式" : "已切换至传统换台模式";
                                            }
                                        } else {
                                            MySettings.get().toggleStartAtPowerOn();
                                            str2 = MySettings.get().isStartAtPowerOn() ? "开机自启已启用" : "开机自启已停用";
                                        }
                                    } else {
                                        MySettings.get().toggleSwitchChannelInAll();
                                        str2 = MySettings.get().isSwitchChannelInAll() ? "跨选分类已开启" : "跨选分类已关闭";
                                    }
                                } else {
                                    MySettings.get().toggleRememberURLIndex();
                                    str2 = MySettings.get().isRememberURLIndex() ? "记忆多源已开启" : "记忆多源已关闭";
                                }
                            } else {
                                MySettings.get().toggleRememberPlay();
                                str2 = MySettings.get().isRememberPlay() ? "记忆播放已开启" : "记忆播放已关闭";
                            }
                        } else {
                            MySettings.get().toggleUseWebDiy();
                            if (MySettings.get().isUseWebDiy()) {
                                a aVar7 = this.m;
                                if (aVar7 != null) {
                                    c.a.a.w.k.l.q(PlayerActivity.this);
                                }
                                str2 = "Web传源已开启";
                            } else {
                                str2 = "Web传源已关闭，需重启才能生效";
                            }
                        }
                    } else {
                        MySettings.get().toggleUseP2p();
                        if (MySettings.get().isUseP2P()) {
                            a aVar8 = this.m;
                            if (aVar8 != null) {
                                c.e.b.a.x(PlayerActivity.this);
                            }
                            str2 = "P2P原力已开启";
                        } else {
                            str2 = "P2P原力已关闭，需重启才能生效";
                        }
                    }
                } else {
                    MySettings.get().toggleExitStyle();
                    str2 = MySettings.get().isQuickExitStyle() ? "已切换至快速退出模式" : "已切换至窗口退出模式";
                }
                k.i.b((Object) str2);
                break;
        }
        this.c.a.a();
    }

    public void f() {
        View view;
        PopupWindow popupWindow = this.h;
        if (popupWindow != null) {
            view = this.f;
        } else {
            PopupWindow popupWindow2 = new PopupWindow(this.f, -2, -1);
            this.h = popupWindow2;
            popupWindow2.setBackgroundDrawable(new ColorDrawable(0));
            this.h.setFocusable(true);
            this.h.setOutsideTouchable(true);
            this.h.update();
            this.h.setOnDismissListener(new q0(this));
            popupWindow = this.h;
            view = this.p;
        }
        popupWindow.showAtLocation(view, 8388613, 0, 0);
        if (this.k) {
            r = 1;
        } else {
            r = -1;
        }
        b();
        this.b.a(t);
        this.f.requestFocus();
        a();
    }
}
